#!/bin/bash
set -x

REGISTRY={{registry_url}}
IMAGE_NAME={{mongodb_image_name}}

CONTAINER_NAME=mongodb

docker rm -f $CONTAINER_NAME

docker run \
  --restart always \
  --name $CONTAINER_NAME \
  --user=$UID:$(id -g $USER) \
  -e MONGODB_INITDB_ROOT_USERNAME={{mongodb_admin_user}} \
  -e MONGODB_INITDB_ROOT_PASSWORD={{mongodb_admin_password}} \
  -p {{mongodb_port}}:27017 \
  -v {{mongodb_deploy_dir}}/mongod.conf:/etc/mongo/mongod.conf \
  -v {{mongodb_deploy_dir}}:/var/run/mongo \
  -v {{mongodb_log_dir}}:/var/log/mongodb \
  -v {{mongodb_data_dir}}:/var/lib/mongo \
  ${REGISTRY}/${IMAGE_NAME} \
  mongod --config /etc/mongo/mongod.conf
